//
//  ValuesTableViewCell.m
//  MyProject
//
//  Created by jiaming yan on 2017/9/12.
//  Copyright © 2017年 yanjiaming. All rights reserved.
//

#import "ValuesTableViewCell.h"
#import "HXTagAttribute.h"
#import "GetComPanyCultureCodeList.h"
#import "GetResumeByUserIdLabelList.h"

@implementation ValuesTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code

}
- (void)setValuesArr:(NSArray *)valuesArr{
    
    self.backHeight.constant = 20+valuesArr.count/4*40+(valuesArr.count%4==0?0:40)+5;
    
    for (UIButton *btn in self.backView.subviews) {
        [btn removeFromSuperview];
    }
    
    for (NSInteger i=0; i<valuesArr.count; i++) {
        
        GetComPanyCultureCodeList *model = valuesArr[i];
        
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(14+(i%4)*((kScreenWidth-38)/4),
                               20+i/4*40,
                               (kScreenWidth-75)/4,
                               25);
        btn.tag = i+100;
        [btn setTitleColor:UIColorFromRGB(0x6C7374) forState:UIControlStateNormal];
        [btn setTitleColor:UIColorFromRGB(0xffffff) forState:UIControlStateSelected];
        [btn setTitle:model.labelName forState:UIControlStateNormal];
        btn.titleLabel.font = k13Font;
        btn.layer.borderColor = UIColorFromRGB(0x1AA9BA).CGColor;
        btn.layer.borderWidth = 0.5;
        btn.layer.cornerRadius = 12.5;
        btn.selected = NO;
        [self.backView addSubview:btn];
    }
}

- (void)compareValueWithSelectedArr:(NSArray *)selectedArr andValuesArr:(NSArray *)valuesArr{
    

    for (NSInteger i=0; i<valuesArr.count; i++) {
        GetComPanyCultureCodeList *modelValue = valuesArr[i];
        for (NSInteger j=0; j<selectedArr.count; j++) {
            GetResumeByUserIdLabelList *modelCurrent = selectedArr[j];
            UIButton *btn = (UIButton *)[self.backView viewWithTag:i+100];
            btn.backgroundColor = UIColorFromRGB(0x1AA9BA);
//            btn.selected = YES;
            if ([modelValue.labelCode isEqualToString:modelCurrent.labelCode]) {
                btn.backgroundColor = UIColorFromRGB(0x1AA9BA);
                btn.selected = YES;
                break;
            }else{
                btn.backgroundColor = UIColorFromRGB(0xffffff);
                btn.selected = NO;
            }
        }
    }
}


//- (GetComPanyCultureCodeList *)theArr:(NSArray *)array Index:(NSInteger)index{
//    if (array.count>index) {
//        return array[index];
//    }else
//        return nil;
//}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
